package model;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import util.SimpleObject;

@XmlRootElement
public class DiaDiemYTe extends ChuDe{
	public static String BENH_VIEN = "Bệnh viện";
	public static String PHONG_KHAM = "Phòng khám";
	
	private LoaiDiaDiemYTe loaiDiaDiemYTe;
	private String thongTin;
	private String diaChi;
	private String soDienThoai;
	private double viDo;
	private double kinhDo;
	private Set<ChuyenKhoa> dsChuyenKhoa;
	private Set<BacSi> dsBacSi;
	private Set<Benh> dsBenhChuyen;
	
	public DiaDiemYTe(){}

	public DiaDiemYTe(String tenChuDe, ChuDe chuDeCha, LoaiDiaDiemYTe loaiDiaDiemYTe, String thongTin, String diaChi, String soDienThoai,
			double viDo, double kinhDo) {
		super(tenChuDe, chuDeCha, chuDeCha.loai);
		this.loaiDiaDiemYTe = loaiDiaDiemYTe;
		this.thongTin = thongTin;
		this.diaChi = diaChi;
		this.soDienThoai = soDienThoai;
		this.viDo = viDo;
		this.kinhDo = kinhDo;
		this.dsChuyenKhoa = new HashSet<ChuyenKhoa>();
		this.dsBacSi = new HashSet<BacSi>();
		this.dsBenhChuyen = new HashSet<Benh>();
	}
	
	public DiaDiemYTe(String tenChuDe, ChuDe chuDeCha, LoaiDiaDiemYTe loaiDiaDiemYTe, String thongTin, String diaChi, String soDienThoai,
			double viDo, double kinhDo, Set<ChuyenKhoa> dsChuyenKhoa, Set<BacSi> dsBacSi, Set<Benh> dsBenhChuyen) {
		super(tenChuDe, chuDeCha, chuDeCha.loai);
		this.loaiDiaDiemYTe = loaiDiaDiemYTe;
		this.thongTin = thongTin;
		this.diaChi = diaChi;
		this.soDienThoai = soDienThoai;
		this.viDo = viDo;
		this.kinhDo = kinhDo;
		this.dsChuyenKhoa = dsChuyenKhoa;
		this.dsBacSi = dsBacSi;
		this.dsBenhChuyen = dsBenhChuyen;
	}
	
	public void addChuyenKhoa(ChuyenKhoa ck){
		dsChuyenKhoa.add(ck);
	}
	
	public void addBacSi(BacSi bs){
		dsBacSi.add(bs);
	}
	public void addBenhChuyen(Benh benh) {
		dsBenhChuyen.add(benh);
	}

	public LoaiDiaDiemYTe getLoaiDiaDiemYTe() {
		return loaiDiaDiemYTe;
	}

	public void setLoaiDiaDiemYTe(LoaiDiaDiemYTe loaiDiaDiemYTe) {
		this.loaiDiaDiemYTe = loaiDiaDiemYTe;
	}

	public String getThongTin() {
		return thongTin;
	}

	public void setThongTin(String thongTin) {
		this.thongTin = thongTin;
	}

	public String getDiaChi() {
		return diaChi;
	}

	public void setDiaChi(String diaChi) {
		this.diaChi = diaChi;
	}

	public String getSoDienThoai() {
		return soDienThoai;
	}

	public void setSoDienThoai(String soDienThoai) {
		this.soDienThoai = soDienThoai;
	}

	public double getViDo() {
		return viDo;
	}

	public void setViDo(double viDo) {
		this.viDo = viDo;
	}

	public double getKinhDo() {
		return kinhDo;
	}

	public void setKinhDo(double kinhDo) {
		this.kinhDo = kinhDo;
	}

	@XmlTransient
	public Set<ChuyenKhoa> getDsChuyenKhoa() {
		return dsChuyenKhoa;
	}

	@XmlElement(name="chuyenKhoa")
	public List<SimpleObject> getDsIdChuyenKhoa(){
		List<SimpleObject> result = new ArrayList<SimpleObject>();
		SimpleObject obj = null;
		for (ChuyenKhoa ck : dsChuyenKhoa) {
			obj = new SimpleObject(ck.getIdChuyenKhoa(), ck.getTenChuyenKhoa());
			result.add(obj);
		}
		return result;
	}
	
	public void setDsChuyenKhoa(Set<ChuyenKhoa> dsChuyenKhoa) {
		this.dsChuyenKhoa = dsChuyenKhoa;
	}

	@XmlTransient
	public Set<BacSi> getDsBacSi() {
		return dsBacSi;
	}

	@XmlElement(name="bacSi")
	public List<SimpleObject> getDsIdBacSi(){
		List<SimpleObject> result = new ArrayList<SimpleObject>();
		SimpleObject obj = null;
		for (BacSi bs : dsBacSi) {
			obj = new SimpleObject(bs.getIdChuDe(), bs.getTenChuDe());
			result.add(obj);
		}
		return result;
	}
	
	public void setDsBacSi(Set<BacSi> dsBacSi) {
		this.dsBacSi = dsBacSi;
	}

	@XmlTransient
	public Set<Benh> getDsBenhChuyen() {
		return dsBenhChuyen;
	}
	
	@XmlElement(name="benhChuyen")
	public List<SimpleObject> getDsIdBenhChuyen(){
		List<SimpleObject> result = new ArrayList<SimpleObject>();
		SimpleObject obj = null;
		for (Benh benh : dsBenhChuyen) {
			obj = new SimpleObject(benh.getIdChuDe(), benh.getTenChuDe());
			result.add(obj);
		}
		return result;
	}

	public void setDsBenhChuyen(Set<Benh> dsBenhChuyen) {
		this.dsBenhChuyen = dsBenhChuyen;
	}

	
	
}
